
package com.v1.video.headline.zerodelivery;

import org.json.JSONObject;

import android.content.ContentValues;
import android.database.Cursor;

import com.iss.bean.BaseBean;
import com.iss.db.TableColumn;

public class ZeroVideoInfo extends BaseBean<ZeroVideoInfo> {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

//    @TableColumn(type = TableColumn.Types.TEXT,  isIndex = true, isNotNull = true)
//    public String name;
//
//    @TableColumn(type = TableColumn.Types.TEXT)
//    public String password;       
    @TableColumn(type = TableColumn.Types.TEXT,  isIndex = true, isNotNull = true)
    public String aid = "";
    @TableColumn(type = TableColumn.Types.TEXT)
    public String title = "";//视频标题    
    @TableColumn(type = TableColumn.Types.TEXT)
    public String create_time = ""; //发布时间     
    public String thumburl = "";//缩略图url
    @TableColumn(type = TableColumn.Types.TEXT)
    public int type = 1;    //0普通状态，可删除,1，默认或更新里有的，不删2，
    public String picpath = "";//缩略图存放地址
    public String playurl = "";//播放地址
    @TableColumn(type = TableColumn.Types.TEXT)
    public String video = "";//下载地址
    @TableColumn(type = TableColumn.Types.TEXT)
    public String duration = "";//播放时长(目前 大于3分钟的不下载)
    public String downLoadtime = "";//下载时间
    public long curSize = 0;//当前大小
    public String intro = "";//描述，简介
    public String href = "";//详情链接,id等信息在这个里面
    @TableColumn(type = TableColumn.Types.TEXT)
    public String videoFilePath = "";//视频存放地址
    @TableColumn(type = TableColumn.Types.TEXT)
    public String videoName = "";//视频名称
    @TableColumn(type = TableColumn.Types.TEXT)
    public String videoExName = "";//扩展名
    @TableColumn(type = TableColumn.Types.TEXT)
    public long totalsize = 0;    
    @TableColumn(type = TableColumn.Types.TEXT)
    public int state = 0;// 0 下载中   1 暂停  2 下载完成        
    public String image = "";
    
    
    
    public InfoState infoState = InfoState.normal;
        
    public ZeroVideoInfo(String videoId,String title,String publishtime,int type,String downurl,String duration,
            String downLoadtime,long size,String videoName,String videoExName,
            String videoFilePath,long totalsize) {
        super();
        initData(videoId,title,publishtime,type,downurl,duration,downLoadtime,size,
                videoName,videoExName,videoFilePath,totalsize);
    }

    public void initData(String videoId,String title,String publishtime,int type,String downurl,String duration,
            String downLoadtime,long curSize,String videoName,String videoExName,
            String videoFilePath,long totalsize){
        this.aid = videoId;
        this.title = title;
        this.create_time = publishtime;
        this.type = type;
        this.video = downurl;
        this.duration = duration;
        this.downLoadtime = downLoadtime;
        this.curSize = curSize;       
        this.videoName = videoName;
        this.videoExName = videoExName;
        this.videoFilePath = videoFilePath;
        this.totalsize = totalsize;
    }
    
    public ZeroVideoInfo() {
        super();
    }

    @Override
    public ZeroVideoInfo parseJSON(JSONObject jsonObj) {
        return null;
    }

    @Override
    public JSONObject toJSON() {
        return null;
    }

    @Override
    public ZeroVideoInfo cursorToBean(Cursor cursor) {
        aid = cursor.getString(cursor.getColumnIndex("aid"));
        title = cursor.getString(cursor.getColumnIndex("title"));
        create_time = cursor.getString(cursor.getColumnIndex("create_time"));
        type = cursor.getInt(cursor.getColumnIndex("type"));
        video = cursor.getString(cursor.getColumnIndex("video"));
        duration = cursor.getString(cursor.getColumnIndex("duration"));
        videoName = cursor.getString(cursor.getColumnIndex("videoName"));
        videoExName = cursor.getString(cursor.getColumnIndex("videoExName"));
        videoFilePath = cursor.getString(cursor.getColumnIndex("videoFilePath"));  
        state =  cursor.getInt(cursor.getColumnIndex("state"));
        totalsize = Long.parseLong(cursor.getString(cursor.getColumnIndex("totalsize")));
        return this;
    }

    @Override
    public ContentValues beanToValues() {
        ContentValues values = new ContentValues();
        values.put("aid", aid);
        values.put("title", title);
        values.put("create_time", create_time);
        values.put("type", type);
        values.put("video", video);
        values.put("duration", duration);
        values.put("videoName", videoName);
        values.put("videoExName", videoExName);
        values.put("videoFilePath", videoFilePath);
        values.put("totalsize", totalsize);
        values.put("state", state);
        return values;
    }
    
    public enum InfoState {
        normal,edit,delete
    }
}
